<?php
namespace App\Params\Backend;
use App\Params\Param;
/**
 * 优惠券列表查询参数
 *
 * @author: WangBin
 * @date: 2021/7/26
 * @mail: <849850352@qq.com>
 */
class GroupListParams extends Param
{
    public $group_name;
    public $page_size = 20;
    public $page = 1;
    public $type;
    public $is_active = 1;

    public function rules()
    {
        return [
            'group_name' => 'nullable|string',
            'page_size' => 'nullable|integer',
            'page' => 'nullable|integer',
            'type' => 'required|string',
            'is_active' => 'nullable|in:0,1'
        ];
    }

    /**
     * @return int
     */
    public function getIsActive(): int
    {
        return (int)$this->is_active;
    }

    /**
     * @param int $is_active
     */
    public function setIsActive(int $is_active): void
    {
        $this->is_active = $is_active;
    }

    /**
     * @return mixed
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @param mixed $type
     */
    public function setType($type): void
    {
        $this->type = $type;
    }

    /**
     * @return mixed
     */
    public function getGroupName()
    {
        return $this->group_name;
    }

    /**
     * @param mixed $group_name
     */
    public function setGroupName($group_name): void
    {
        $this->group_name = $group_name;
    }

    /**
     * @return int
     */
    public function getPageSize(): int
    {
        return $this->page_size;
    }

    /**
     * @param int $page_size
     */
    public function setPageSize(int $page_size): void
    {
        $this->page_size = $page_size;
    }

    /**
     * @return int
     */
    public function getPage(): int
    {
        return $this->page > 0 ? -- $this->page : 0;
    }

    /**
     * @param int $page
     */
    public function setPage(int $page): void
    {
        $this->page = $page;
    }
}
